package com.rran.study.designpattern.behavioral.strategy.factory;

import com.rran.study.designpattern.behavioral.strategy.enums.PayStretegyClassEnums;
import com.rran.study.designpattern.behavioral.strategy.strategy.PayStrategy;

/**
 * @author yy
 * @Type PayStretegyRefleftEnumFactory.java
 * @Desc 策略工厂(通过枚举反射获取) 优点：符合开闭原则
 * @date 2020/7/20 12:32
 */
public class PayStretegyRefleftEnumFactory {

    public static PayStrategy getPayStrategy(String name) throws Exception {
        String className = PayStretegyClassEnums.valueOf(name).getClassName();
        return (PayStrategy) Class.forName(className).newInstance();
    }
}
